package business_logic.view;

import fiuba.algo3.titiritero.modelo.SuperficieDeDibujo;

public final class ExplosionView implements GameView
{
    static final int m_zIndex = 20;
    
    static final Image m_defaultImage = new Image("/images/explosion.png");
    
    final Animation m_deadAnimation;
    final Observable m_observable;
    
    public ExplosionView( Observable observable )
    {
        m_observable = observable;
        m_deadAnimation = new ReduceAnimation(m_defaultImage, 4);
    }
    
    @Override
    public void dibujar(SuperficieDeDibujo graphicSurface)
    {
        if( m_observable.isAlive() )
        {
            m_defaultImage.draw( m_observable.getX(), m_observable.getY(), graphicSurface );
        }
        else
        {
            m_deadAnimation.draw( m_observable.getX(), m_observable.getY(), graphicSurface );
        }

    }

    @Override
    public boolean isDone()
    {
        if ( m_observable.isAlive() || !m_deadAnimation.isDone() )
            return false;
        else
            return true;
    }

    @Override
    public int getZIndex()
    {
        return m_zIndex;
    }
}
